﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows;
using System.Windows.Data;
using System.Collections;
using Dominion.WPF.Services;
using Dominion.Core;

namespace Dominion.WPF.ViewModels
{
    public abstract class ViewModelBase : INotifyPropertyChanged
    {
        protected ViewModelBase()
        {

        }

        #region Tools

        protected ICollectionView CreateGroupCollectionViewFor(IList cards, string propertyName, Predicate<object> filter)
        {
            ICollectionView view = new ListCollectionView(cards);
            view.Filter = filter;
            view.GroupDescriptions.Add(new PropertyGroupDescription(propertyName));
            //view.SortDescriptions.Add(new SortDescription("Price", ListSortDirection.Ascending));
            return view;
        }

        #endregion

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                var e = new PropertyChangedEventArgs(propertyName);
                handler(this, e);
            }
        }
        #endregion

    }
}
